package com.tms.project.tms.manage.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.tms.framework.aspectj.lang.annotation.Log;
import com.tms.framework.aspectj.lang.enums.BusinessType;
import com.tms.project.tms.manage.domain.TeachingManage;
import com.tms.project.tms.manage.service.ITeachingManageService;
import com.tms.framework.web.controller.BaseController;
import com.tms.framework.web.domain.AjaxResult;
import com.tms.common.utils.poi.ExcelUtil;
import com.tms.framework.web.page.TableDataInfo;

/**
 * 常规教学管理Controller
 * 
 * @author xyl
 * @date 2021-03-23
 */
@Controller
@RequestMapping("/tms/manage")
public class TeachingManageController extends BaseController
{
    private String prefix = "tms/manage";

    @Autowired
    private ITeachingManageService teachingManageService;

    @RequiresPermissions("tms:manage:view")
    @GetMapping()
    public String manage()
    {
        return prefix + "/manage";
    }

    /**
     * 查询常规教学管理列表
     */
    @RequiresPermissions("tms:manage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TeachingManage teachingManage)
    {
        startPage();
        List<TeachingManage> list = teachingManageService.selectTeachingManageList(teachingManage);
        return getDataTable(list);
    }

    /**
     * 导出常规教学管理列表
     */
    @RequiresPermissions("tms:manage:export")
    @Log(title = "常规教学管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TeachingManage teachingManage)
    {
        List<TeachingManage> list = teachingManageService.selectTeachingManageList(teachingManage);
        ExcelUtil<TeachingManage> util = new ExcelUtil<TeachingManage>(TeachingManage.class);
        return util.exportExcel(list, "manage");
    }

    /**
     * 新增常规教学管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存常规教学管理
     */
    @RequiresPermissions("tms:manage:add")
    @Log(title = "常规教学管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TeachingManage teachingManage)
    {
        return toAjax(teachingManageService.insertTeachingManage(teachingManage));
    }

    /**
     * 修改常规教学管理
     */
    @GetMapping("/edit/{teachingManageId}")
    public String edit(@PathVariable("teachingManageId") Long teachingManageId, ModelMap mmap)
    {
        TeachingManage teachingManage = teachingManageService.selectTeachingManageById(teachingManageId);
        mmap.put("teachingManage", teachingManage);
        return prefix + "/edit";
    }

    /**
     * 修改保存常规教学管理
     */
    @RequiresPermissions("tms:manage:edit")
    @Log(title = "常规教学管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TeachingManage teachingManage)
    {
        return toAjax(teachingManageService.updateTeachingManage(teachingManage));
    }

    /**
     * 删除常规教学管理
     */
    @RequiresPermissions("tms:manage:remove")
    @Log(title = "常规教学管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(teachingManageService.deleteTeachingManageByIds(ids));
    }
}
